
import java.util.*;

/**
 * NC230720:小红的ABC
 * https://ac.nowcoder.com/acm/problem/230720
 */
 class Main1{
    public static void main(String[] args){
        Scanner in  = new Scanner(System.in);

        char[] s = in.next().toCharArray();
        int n = s.length;

        int ret = -1;
        for(int i = 0;i < n;i++){
            if(i + 1 < n && s[i] == s[i+1]){
                ret = 2;
                break;
            }
            if(i + 2 < n && s[i] == s[i + 2]){
                ret = 3;
            }
        }

        System.out.println(ret);
    }
}
/**
 * 不相邻的数
 * dp23
 */
class Main2
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int f[] = new int[n + 1];
        int g[] = new int[n + 1];

        for(int i = 1;i <= n;i++){
            int x = in.nextInt();

            f[i] = g[i-1] + x;
            g[i] = Math.max(g[i-1],f[i -1]);
        }

        System.out.println(Math.max(g[n],f[n]));

    }
}


/**
 * NC229310 空调遥控
 * https://ac.nowcoder.com/acm/problem/229310
 * 滑动窗口 + 数学
 */
class Main3{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int n = in.nextInt(),p = in.nextInt();

        int[] arr = new int[n];
        for(int i = 0;i < n;i++) arr[i] = in.nextInt();

        Arrays.sort(arr);

        int left = 0,right = 0,count = 0;
        int t = 2 * p;
        while(right < n){
            //1。进入窗口

            //2.判断
            while(arr[right] - arr[left] > t){
                //3.出窗口
                left++;
            }

            //3.更新
            count = Math.max(count,right - left + 1);
            right++;
        }

        System.out.println(count);
    }
}
/*
二分查找
 */
class Main3_2{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int n = in.nextInt(),p = in.nextInt();

        int[] arr = new int[n];
        for(int i = 0;i < n;i++) arr[i] = in.nextInt();

        Arrays.sort(arr);

        //遍历每一个温度，定义遍历count统计
        int count = 0;
        for(int i = 0;i < n;i++){
            int lt = arr[i] - p;
            int rt = arr[i] + p;

            //二分查找左右端点下标
            //左端点
            int left = 0;
            int right = n -1;
            while(left < right){
                int mid = left + (right - left) / 2;

                if(arr[mid] < lt) left = mid + 1;
                else right = mid;
            }
            int l = left;

            left = 0;
            right = n-1;
            while(left < right){
                int mid = left + (right - left + 1) / 2;
                if(rt < arr[mid]) right = mid - 1;
                else left = mid;
            }
            int r = right;

            count = Math.max(count,r - l + 1);
        }
        System.out.println(count);
    }
}